#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import logging
import time
import datetime
import os
import simplejson
import random
import sys
#sys.setdefaultencoding("utf-8")
#print sys.getdefaultencoding()
class JST(datetime.tzinfo):
    def __init__(self, hour=0):
        """
            時間計算
        """
        self.td=datetime.timedelta(hours=9)#TimeZone
        self.TimeZone=datetime.datetime.today() + self.td
        #self.response.out.write("%s" % ( jt.strftime("%Y年%m月%d日 %H時%M分%S秒") ))
    def Get(self):
        return self.TimeZone
    def PrintJPN(self):
        return self.TimeZone.strftime("%Y年%m月%d日 %H時%M分%S秒")

class Bweet():
    def __init__(self,word=u" #ブッッッヒャー #boooobots"):
        self.word=word
    def Get(self):
        word = {
            "bu":[u"ぶっ",u"ブッ"],
            "hy":[u"ひゃ",u"ヒャ"],
            "a":[u"ー",u"〜"]
            }
        jt=JST(hour=9)
        tag = self.word + u" %s" % str(jt.PrintJPN()).decode("UTF-8")
        counts=139-len(tag)
        boo = ''
        for i in range(random.randint(1,18)):
            for k in range(random.randint(1,4)):
                boo += word["bu"][random.randint(0,1)]
            for k in range(random.randint(1,3)):
                boo += word["hy"][random.randint(0,1)]
            for k in range(random.randint(1,10)):
                boo += word["a"][1]
        if len(boo) > counts:
            boo_tmp=""
            for i in range(counts):
                boo_tmp+=boo[i]
            boo=boo_tmp
        m=boo + tag
        return m.encode("UTF-8")
